﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yitter.IdGenerator;

namespace PLM.ConfigurationCenter.Core {
    public class CommonHelper {
        /// <summary>
        /// 获取唯一Id
        /// </summary>
        /// <returns></returns>
        public static long GetSingleId() {
            return YitIdHelper.NextId();
        }
        #region 文件
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name=""></param>
        public static void WriteFile(string filePath, List<string> strList) {
            //创建StreamWriter 类的实例
            StreamWriter streamWriter = new StreamWriter(filePath);
            //向文件中写入内容
            foreach (string str in strList) {
                streamWriter.WriteLine(str);
            }
            //刷新缓存
            streamWriter.Flush();
            //关闭流
            streamWriter.Close();
        }
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name=""></param>
        public static void WriteFile(string filePath, string content) {
            //创建StreamWriter 类的实例
            StreamWriter streamWriter = new StreamWriter(filePath);
            //向文件中写入内容
            streamWriter.WriteLine(content);
            //刷新缓存
            streamWriter.Flush();
            //关闭流
            streamWriter.Close();
        }
        #endregion

    }
}
